package cn.com.cfae.iras.doc.analyze.components.beans;

import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 佟媛媛 on 18/10/30.
 * 各个组件返回结构
 */
public class ComponentResult {
    private String catalogId;//章节ID
    private String chapterId;//子章节ID
    private String ruleName;//规则名
    private String uid;//自定义ID
    private String keyword;//检查内容
    private String promptMessage;//提示信息
    private Boolean annotationFlag;//匹配到关键字则false，未匹配到关键字则true
    private String regulationId;//规则ID
    private Integer pageNum;//页码
    private List<TextPosition> textPosition;//坐标
    /**
     * exist取值及含义
     *
     *      完整性         一致性        合理性       常识性
     *
     * 01   已披露         正确          合理
     * 02   未披露         冲突          不合理       错误
     * 03   疑似披露       可能正确       待确认       疑似错误
     * 04                 一次出现
     */
    private String exist;

    public String getCatalogId() {
        return catalogId;
    }

    public void setCatalogId(String catalogId) {
        this.catalogId = catalogId;
    }

    public String getChapterId() {
        return chapterId;
    }

    public void setChapterId(String chapterId) {
        this.chapterId = chapterId;
    }

    public String getRuleName() {
        return ruleName;
    }

    public void setRuleName(String ruleName) {
        this.ruleName = ruleName;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getPromptMessage() {
        return promptMessage;
    }

    public void setPromptMessage(String promptMessage) {
        this.promptMessage = promptMessage;
    }


    public String getRegulationId() {
        return regulationId;
    }

    public void setRegulationId(String regulationId) {
        this.regulationId = regulationId;
    }


    public List<TextPosition> getTextPosition() {
        return textPosition;
    }

    public void setTextPosition(List<TextPosition> textPosition) {
        if(CollectionUtils.isEmpty(textPosition)){
            this.textPosition = new ArrayList<>();
        }else{
            List<TextPosition> _textPosition = new ArrayList<>();
            for(TextPosition position : textPosition){
                if(!(position.getX()==0 && position.getY()==0)){
                    _textPosition.add(position);
                }
            }
            this.textPosition = _textPosition;
        }
    }

    public String getExist() {
        return exist;
    }

    public void setExist(String exist) {
        this.exist = exist;
    }

    public Boolean getAnnotationFlag() {
        return annotationFlag;
    }

    public void setAnnotationFlag(Boolean annotationFlag) {
        if(annotationFlag==null){
            this.annotationFlag = false;
        }else{
            this.annotationFlag = annotationFlag;
        }
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        if(pageNum==null){
            this.pageNum = 0;
        }else{
            this.pageNum = pageNum;
        }
    }


    public class TextPosition{
        private double x;
        private double y;
        private String content;

        public double getX() {
            return x;
        }

        public void setX(double x) {
            this.x = x;
        }

        public double getY() {
            return y;
        }

        public void setY(double y) {
            this.y = y;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
    }
}
